<!--
 * @Date: 2022-01-19 10:10:12
 * @LastEditTime: 2022-11-05 09:09:12
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    // 1. 利用set结构写法
    // 时间复杂度还可以
    var containsDuplicate = function (nums) {
      let set = new Set(nums)
      return set.size === nums.length ? false : true
    }
    console.log(containsDuplicate([1, 3, 5, 4]))
    console.log(containsDuplicate([1, 3, 5, 4, 4]))
  </script>
</body>

</html>